Python Launcher (通过 py |
您所在的位置:网站首页 › python 为所有用户安装 › Python Launcher (通过 py |
1. 什么是 Python Launcher
原文: New in version 3.3. The Python launcher for Windows is a utility which aids in locating and executing of different Python versions. It allows scripts (or the command-line) to indicate a preference for a specific Python version, and will locate and execute that version. Unlike the PATH variable, the launcher will correctly select the most appropriate version of Python. It will prefer per-user installations over system-wide ones, and orders by language version rather than using the most recently installed version. -----来源于 python 官方文档 翻译: 3.3版本新增功能 适用于 Windows 的 Python 启动器是一个实用组件,可帮助您定位和执行不同的 Python 版本。它允许脚本(或命令行)为特定的 Python 版本指示首选项,定位并执行该版本。 不同于 PATH 变量,Python Launcher 将正确选择最合适的 Python 版本。它更喜欢每个用户在系统范围内的安装,并且运行指定的 Python 版本,而不是使用最近安装的版本。 2. Python Launcher 的位置在安装 Python 3.3 以上版本的 Python 时,我们可以看到下图中的一个选项,当我们勾选时,系统便会帮助我们自动安装 Python Launcher image当点击 Customize installation 时,会显示如下界面: image图中标注的小字告诉我们,安装 Python Launcher 后可以通过全局命令 ‘py’ 来更方便地启动 Python。不勾选 launcher 项时,系统则不会安装 Python Launcher (但默认情况下该工具都是被勾选的)。 安装好后,我们可以通过注册表和系统文件管理器中找到 py.exe 的位置: 仅为当前用户安装时: image image 为所有用户安装时: image image 3. Python Launcher 的环境变量为什么 Python Launcher 不需要手动配置环境变量呢? 当为所有用户安装时,我们会发现 py.exe 被自动安装到 C:\Windows 下了,当我们检查系统默认设置的环境变量时,可以看到下图中的 windir 的值已经默认设置为 C:\Windows ,这第一点对于所有 Windows 系统都是相同的 ,系统安装的时候便会做这些工作。 image.png当仅为当前用户安装时,我们会发现 py.exe 所在的路径会自动添加到系统的用户变量中: image.png因此,无论以哪种方式安装 Python Launcher 我们都不需要再手动配置环境变量了。 4. Python Launcher 的用法Python Launcher 的使用方法我们可以通过在命令行中输入 py -h 进行查看,如下图: image同样地,我们也可以通过查阅官方文档进行了解 https://docs.python.org/3/using/windows.html#launcher image 5. 结语综上所述,py -version 启动 python 的方式其实应该是官方更为推崇的一种方式,无需手动设置环境变量,并且能指定启动 python 的版本,功能不要太强大!绝对是在多版本 Python 共存的环境下,启动不同版本 Python 的利器! 当是需要注意的是,Python Launcher 是 Python3.3 以上版本中新增的组件,并且可以独立地安装和卸载,使用时一定要注意 Python Launcher 被正确地安装在系统中了,否则就会报 'py' 不是内部或外部命令,也不是可运行的程序或批处理文件 的错误,一定要注意哦! 好了,本期调研的全部内容到这里就结束了,感谢大家阅览!(づ ̄ 3 ̄)づ 我们下期再见! [好累 ┭┮﹏┭┮ ,不要再有下期了...] |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |